package com.hqz.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 用户表
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("users")
public class Users extends BaseEntity {

    @TableId(type = IdType.AUTO)
    private Integer usersId; //超级管理员I
    private String usersName; //账号
    private String pwd; //密码
    private String salt;
    private Integer age;
    private String sex;
    private String phone;
    private String address;

    /**
     * 密码盐. 重新对盐重新进行了定义，用户名+salt，这样就更加不容易被破解
     * @return
     */
    public String getCredentialsSalt(){
        return this.usersName + this.salt;
    }

    @TableField(exist = false)
    private List<Role> roleList;

}
